home *** CD-ROM | disk | FTP | other *** search
/ PCMania 13 / Pcmania_Ep2_13_CD-01.iso / Programas para CD / MPEG4.ZIP / DVD-AVI (MPEG4) Fundamentales / Virtual Dub / Smart.txt < prev    next >
Encoding:
Text File  |  2000-03-25  |  6.2 KB  |  109 lines

  1. Smart Deinterlacing Filter for Virtual Dub
  2.  
  3. [Place this text file in the VirtualDub plugins directory to make
  4. it available via the Help button on the filter configuration dialog
  5. box. The computer must have a program called Notepad available in
  6. its search path.]
  7.  
  8. This filter provides a smart, motion-based deinterlacing capability. In static
  9. picture areas, interlacing artifacts do not appear, so data from both fields is
  10. used to provide full detail. In moving areas, deinterlacing is performed.
  11. Details on the algorithm used are available below.
  12.  
  13. The following options are available:
  14.  
  15. Motion Processing
  16.  
  17. Show motion areas only: When selected, only the moving areas of the image
  18. are displayed; static areas are black. This option can be used to assess the
  19. suitability of the choice of threshold (see below).
  20.  
  21. Blend instead of interpolate in motion areas: If this checkbox is not selected,
  22. then, in motion areas, the filter will discard one field's data and recreate it
  23. by interpolating new lines from the retained field's lines. In static areas, both
  24. field's data is used. If this checkbox is checked, then, in motion areas, instead
  25. of interpolating, the filter blends each line with the lines above and below. This
  26. has the effect of blending the fields, which tends to blur out the interlacing
  27. artifacts. The choice of interpolation versus blending depends on the nature of
  28. the input video and your own esthetic preferences. The interpolate mode avoids
  29. the halos you can get with the blend mode, but it introduces some small amount
  30. of stairstepping, and may tend to emphasize any video noise that is present. Try
  31. both ways and see which you prefer for a given video clip.
  32.  
  33. Threshold: This value determines the difference between a pixel and its corresponding
  34. value in the previous frame that must be exceeded for the pixel to be considered moving.
  35. The threshold should be chosen to be as high as possible while still removing the
  36. interlacing artifacts. The default threshold (20) is fine for most applications, but may
  37. need to be adjusted for different input video. You can view its effect on motion detection
  38. by selecting the "Show motion areas only" checkbox.
  39.  
  40. Advanced Processing
  41.  
  42. Phase shift by one field: Consider a frame/field sequence of progressive video
  43. AA BB CC DD EE... This is correct because each frame contains the correct field data
  44. from the original progressive frame. Suppose, as often happens, the stream is
  45. encoded and broadcasted for display on today's interlaced TVs, but the encoding is
  46. off by one field. Then we receive ...A AB BC CD DE E... The picture will look fine on
  47. the interlaced display, but it will appear to be strangely interlaced when captured
  48. to a computer and displayed progressively. Apparently, this is a common problem in the
  49. PAL world when films are digitized. This option, when enabled, simply shifts the field
  50. phase by one and recreates the correct progressive frames. Because correct progressive
  51. frames are the result, the full motion detection deinterlacing described above is not required
  52. and is disabled. If you see strange interlacing for PAL video, it is worth trying this option
  53. before resorting to full deinterlacing, because it may allow the full resolution of the
  54. video to be retained for each entire frame. Please note that, due to the way that this
  55. filter buffers frames internally, it may appear to not work corrctly when scrubbing the
  56. time line or when single stepping backward. But single stepping forward will always work
  57. and, of course, saved processed video will always be correct.
  58.  
  59. Note on 3:2 Pulldown, Etc.
  60.  
  61. Some video streams are created from progressive video by a process called pulldown.
  62. This results in a mixture of progressive and interlaced frames, from which it is theoretically
  63. possible to recreate the original progressive frames without doing deinterlacing.
  64. However, it is technically very challenging to write a filter that will recreate the original
  65. frames for all types of pulldown and in the presence of video edits, etc. While my goal
  66. is to eventually make available such processing via options, the technology is not yet
  67. ready. In the meantime, the normal deinterlacing will function quite acceptably for the
  68. majority of these video streams. 
  69.  
  70. Technical details on the algorithm follow:
  71.  
  72. We really should place the word motion as used in this context in quotes,
  73. because real motion detection algorithms as you might find in, say, MPEG
  74. encoding are not used as they would be too slow. Instead, "motion"
  75. is estimated by comparing a pixel's value to its value in the previous frame.
  76. If the difference exceeds a configurable threshold, the pixel is considered to
  77. be in a moving area. Here is a description of the full process:
  78.  
  79. 1. The frame is scanned and for each pixel, it is determined whether it is
  80. moving or not based on a thresholded color difference calculation.
  81. The difference calculation goes as follows: If the difference between the
  82. blue components exceeds threshold, or the difference between the red
  83. components exceeds threshold, or the difference between the green
  84. components exceeds threshold, then the pixel is considered to be in a
  85. moving area.
  86.  
  87. 2. To eliminate combing at the edge of the motion areas, the following
  88. heuristic is used: For each pixel in the frame calculated to be non-moving,
  89. promote it to moving if it has moving pixels immediately above it or below it.
  90.  
  91. 3. Pass non-moving pixels directly through to the output. If the blend checkbox
  92. is not checked: Pass even lines directly through. For odd lines, recreate each
  93. pixel by taking the average of the pixel above and the pixel below (this amounts to
  94. line interpolation). If the blend checkbox is checked: Make each pixel by taking a
  95. weighted average of the source pixel (0.5 weight) and the above and below pixels
  96. (0.25 weight each). So it can be seen that in the moving areas, the interpolate
  97. mode throws away information from one field, while the blend mode retains
  98. some of it.
  99.  
  100. For additional information, version updates, and other filters, please
  101. go to the following web site:
  102.  
  103. Filters for VirtualDub
  104. http://www.geocities.com/Colosseum/Pressbox/8699/index.html
  105.  
  106. Donald Graft
  107. March 24, 2000
  108. (C) Copyright 2000, All Rights Reserved
  109.